﻿using System;
using System.Collections.Generic;
using System.Text;



namespace forum_iteration1.Forum
{
    public class Thread
    {
        private string        _header;
        private string        _content;
        private int           _numOfReplies;
        private int           _numOfViews;
        private User          _creator;
        private DateTime      _publishDate;
        private DateTime      _lastDate;
        private List<Post>    _postList;
        

        public Thread(string header,string content, User creatorName)
        {
            _header = header;
            _content = content;
            _numOfReplies = 0;
            _numOfViews = 0;
            _creator = creatorName;
            _publishDate = DateTime.Now;
            _lastDate = DateTime.Now;
            _postList = new List<Post>();
        }
        public string Header { get { return _header; }  }
        public int NumOfReplies { get { return _numOfReplies; } set { _numOfReplies = value; } }
        public int NumOfViews { get { return _numOfViews; } set { _numOfViews = value; } }
        public DateTime PublishDate { get { return _publishDate; } }
        public DateTime LastDate { get { return _lastDate; } }
        public List<Post> PostList { get { return _postList; } }
        public User Creator { get { return _creator; } }
        public string Content { get { return _content; } set { _content = value; } }


        /// <summary>
        /// add new post to the thread list
        /// </summary>
        /// <param name="p"> the new post </param>
        public void addNewPost(Post p)
        {
            _postList.Add(p);
            _lastDate = DateTime.Now;
        }

    }
}
